package com.jtny.nytb.controller;

import com.jtny.component.annotation.LoginFunction;
import com.jtny.component.core.entity.DataSourceContextHolder;
import com.jtny.component.saas.domain.TenantDataSourceDO;
import com.jtny.component.saas.service.TenantDataSourceService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author 智慧能源中心 - xqx
 * @package com.jtny.nytb.energymonitor.controller
 * @fileName jtny-nytb-energymonitor-equipment
 * @Copyright© 2024 jtny
 * @Date 2024/7/12
 * 江投能源技术研究院 版权所有
 */
@RestController
@RequestMapping("test")
public class TestController {

    @Resource
    TenantDataSourceService tenantDataSourceService;

    @LoginFunction
    @GetMapping("noTsso")
    public String noTsso() {
        TenantDataSourceDO db = tenantDataSourceService.getTenantDataSourceByTenantCode("jxs_tzds", "jtny-nytb-config-organization-server");
        return db.getUrl();
    }

    @LoginFunction
    @GetMapping("tsso")
    public String tsso() {
        return DataSourceContextHolder.getDataSourceKey();
    }
}
